package com.ruoyi.slope.video.radar.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.slope.dataFile.domain.SlopeDataFile;
import com.ruoyi.slope.dataFile.service.ISlopeDataFileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.slope.video.radar.domain.RadarMonitoringPng;
import com.ruoyi.slope.video.radar.service.IRadarMonitoringPngService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 雷达监测图片数据Controller
 * 
 * @author ruoyi
 * @date 2025-08-28
 */
@RestController
@RequestMapping("/radar/img")
public class RadarMonitoringPngController extends BaseController
{    
    @Autowired
    private ISlopeDataFileService slopeDataFileService;
    @Autowired
    private IRadarMonitoringPngService radarMonitoringPngService;

    /**
     * 查询雷达监测图片数据列表
     */
    @PreAuthorize("@ss.hasPermi('radar:img:list')")
    @GetMapping("/list")
    public TableDataInfo list(RadarMonitoringPng radarMonitoringPng)
    {
        startPage();
        List<RadarMonitoringPng> list = radarMonitoringPngService.selectRadarMonitoringPngList(radarMonitoringPng);
        return getDataTable(list);
    }

    /**
     * 导出雷达监测图片数据列表
     */
    @PreAuthorize("@ss.hasPermi('radar:img:export')")
    @Log(title = "雷达监测图片数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RadarMonitoringPng radarMonitoringPng)
    {
        List<RadarMonitoringPng> list = radarMonitoringPngService.selectRadarMonitoringPngList(radarMonitoringPng);
        ExcelUtil<RadarMonitoringPng> util = new ExcelUtil<RadarMonitoringPng>(RadarMonitoringPng.class);
        String path = util.exportExcel(response, list, "雷达监测图片数据数据"); 
        SlopeDataFile slopeDataFile = new SlopeDataFile();
        slopeDataFile.setFileName(path);
        slopeDataFileService.insertSlopeDataFile(slopeDataFile);
    }

    /**
     * 获取雷达监测图片数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('radar:img:query')")
    @GetMapping(value = "/{atTime}")
    public AjaxResult getInfo(@PathVariable("atTime") Date atTime)
    {
        return success(radarMonitoringPngService.selectRadarMonitoringPngByAtTime(atTime));
    }

    /**
     * 新增雷达监测图片数据
     */
    @PreAuthorize("@ss.hasPermi('radar:img:add')")
    @Log(title = "雷达监测图片数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RadarMonitoringPng radarMonitoringPng)
    {
        return toAjax(radarMonitoringPngService.insertRadarMonitoringPng(radarMonitoringPng));
    }

    /**
     * 修改雷达监测图片数据
     */
    @PreAuthorize("@ss.hasPermi('radar:img:edit')")
    @Log(title = "雷达监测图片数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RadarMonitoringPng radarMonitoringPng)
    {
        return toAjax(radarMonitoringPngService.updateRadarMonitoringPng(radarMonitoringPng));
    }

    /**
     * 删除雷达监测图片数据
     */
    @PreAuthorize("@ss.hasPermi('radar:img:remove')")
    @Log(title = "雷达监测图片数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{atTimes}")
    public AjaxResult remove(@PathVariable Date[] atTimes)
    {
        return toAjax(radarMonitoringPngService.deleteRadarMonitoringPngByAtTimes(atTimes));
    }
}
